Sys.setlocale("LC_CTYPE", "en_US.UTF-8")
## [1] "en_US.UTF-8"
MRT_1F <- c(517.1468515630205, 85.13094142168089, 30.333207896694553, 12.694776264558937, 3.3041601673945418, 1.1823111717498882, 1.1892293502386786)
MRT_3F <- c(156.68929936163462, 11.540837783562276, 0.4512835621696538, 0.4509797929766453, 0.4502068233039181, 0.4496185276300172, 0.4543157082191288)
MRT_5F <- c(83.90319666471157, 0.3068151086494968, 0.30522314133037304, 0.3072588968084928, 0.30655265997285697, 0.3055812715727718, 0.3053297166713006)
MRT_10F <- c(29.55430642951759, 0.19832832665772515, 0.1971923924717474, 0.19796648905716516, 0.19615594370806338, 0.2034569237883263, 0.19617420889447737)
MRT_15F <- c(11.317736530583566, 0.167364215666193, 0.16172168266811013, 0.16701085329580515, 0.1598052657153692, 0.1645934043532696, 0.16216563797118075)
MRT_sem_F <- c(11.93430909937736, 0.6095414637034009, 0.6060645101029295, 0.612167181646899, 0.6146761002685637, 0.6096747087200697, 0.6125810476877268)
clock <- c(0.1, 0.5, 1, 1.5, 2, 2.5, 3)
plot(clock, MRT_1F, type = "o", col = "black", pch = 4,
ylim = c(min(MRT_1F, MRT_3F, MRT_5F, MRT_10F, MRT_15F, MRT_sem_F),
max(MRT_1F)),
ylab = "Response Time (Sec)",
xlab = "Time Between Things Requests (seconds)")
lines(clock, MRT_3F, type = "o", col = "yellow", pch = 3)
lines(clock, MRT_5F, type = "o", col = "red", pch = 1)
lines(clock, MRT_10F, type = "o", col = "blue", pch = 2)
lines(clock, MRT_15F, type = "o", col = "purple", pch = 5)
lines(clock, MRT_sem_F, type = "o", col = "green", pch = 4)
legend("topright", legend = c("1 Fog", "3 Fogs", "5 Fogs", "10 Fogs", "15 Fogs", "w/o Fog"),
col = c("black", "yellow", "red", "blue", "purple", "green"),
pch = c(4, 3, 1, 2, 5, 4), # Define os símbolos corretamente
lty = 1)
barplot(matrix(c(MRT_sem_F, MRT_1F), nrow = 2, byrow = TRUE), beside = TRUE, col = c("#E6E6E6", "#666666"), log = "y", names.arg = clock, ylab = "Response Time (s)", xlab = "Time between Things requests")
legend("topright", legend = c("w/o Fog", "1 Fog"), col = c("gray", "black"), pch = c(0,15))
barplot(matrix(c(MRT_sem_F, MRT_3F), nrow = 2, byrow = TRUE), beside = TRUE, col = c("#E6E6E6", "#666666"), log = "y", names.arg = clock, ylab = "Response Time (s)", xlab = "Time between Things requests")
legend("topright", legend = c("w/o Fog", "3 Fogs"), col = c("gray", "black"), pch = c(0,15))
barplot(matrix(c(MRT_sem_F, MRT_5F), nrow = 2, byrow = TRUE), beside = TRUE, col = c("#E6E6E6", "#666666"), log = "y", names.arg = clock, ylab = "Response Time (s)", xlab = "Time between Things requests")
legend("topright", legend = c("w/o Fog", "5 Fogs"), col = c("gray", "black"), pch = c(0,15))
barplot(matrix(c(MRT_sem_F, MRT_10F), nrow = 2, byrow = TRUE), beside = TRUE, col = c("#E6E6E6", "#666666"), log = "y", names.arg = clock, ylab = "Response Time (s)", xlab = "Time between Things requests")
legend("topright", legend = c("w/o Fog", "10 Fogs"), col = c("gray", "black"), pch = c(0,15))
barplot(matrix(c(MRT_sem_F, MRT_15F), nrow = 2, byrow = TRUE), beside = TRUE, col = c("#E6E6E6", "#666666"), log = "y", names.arg = clock, ylab = "Response Time (s)", xlab = "Time between Things requests")
legend("topright", legend = c("w/o Fog", "15 Fogs"), col = c("gray", "black"), pch = c(0,15))
dados <- data.frame(
Qualidade = c("Good", "Very Good", "Excellent"),
`10-19` = c(53.8, 43.6, 2.6),
`20-29` = c(33.9, 54.2, 11.9),
`30-39` = c(2.6, 60.5, 36.8),
`40-49` = c(0.0, 21.4, 78.6)
)
dados_matrix <- as.matrix(dados[, 2:5])
barplot(dados_matrix, beside = FALSE,
col = c("#4C72B0", "#DD8452", "#55A868"),
xlab = "Meal Price",
ylab = "Percentage",
main = "Quality Rating by Meal Price",
legend.text = dados$Qualidade,
args.legend = list(x = "topright", inset = c(0, -0.31)))
library(ggplot2)
library(dplyr)
##
## Anexando pacote: 'dplyr'
## Os seguintes objetos são mascarados por 'package:stats':
##
## filter, lag
## Os seguintes objetos são mascarados por 'package:base':
##
## intersect, setdiff, setequal, union
airquality$Temp_C <- (airquality$Temp - 32) / 1.8
dados_maio <- subset(airquality, Month == 5, select = Temp_C)
ggplot(dados_maio, aes(x = Temp_C)) +
geom_histogram(aes(y = ..density..), binwidth = 1, fill = "blue", color = "black", alpha = 0.7) +
geom_density(color = "red", size = 1.2) +
labs(title = "Histograma das Temperaturas de Maio",
x = "Temperatura (°C)",
y = "Densidade") +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
### Questão 4
The requested URL was not found on this server.
data("InsectSprays")
ggplot(InsectSprays, aes(x = spray, y = count, fill = spray)) +
geom_boxplot(outlier.shape = NA, fill = "yellow", color = "black") +
labs(title = "Boxplot das Contagens de Insetos por Inseticida",
x = "Tipo de Inseticida",
y = "Contagem de Insetos") +
theme_minimal()
library(dplyr)
library(plotly)
##
## Anexando pacote: 'plotly'
## O seguinte objeto é mascarado por 'package:ggplot2':
##
## last_plot
## O seguinte objeto é mascarado por 'package:stats':
##
## filter
## O seguinte objeto é mascarado por 'package:graphics':
##
## layout
netflix_data <- read.csv("netflix_titles.csv")
head(netflix_data)
## show_id type title director
## 1 s1 TV Show 3%
## 2 s2 Movie 7:19 Jorge Michel Grau
## 3 s3 Movie 23:59 Gilbert Chan
## 4 s4 Movie 9 Shane Acker
## 5 s5 Movie 21 Robert Luketic
## 6 s6 TV Show 46 Serdar Akar
## cast
## 1 João Miguel, Bianca Comparato, Michel Gomes, Rodolfo Valente, Vaneza Oliveira, Rafael Lozano, Viviane Porto, Mel Fronckowiak, Sergio Mamberti, Zezé Motta, Celso Frateschi
## 2 Demián Bichir, Héctor Bonilla, Oscar Serrano, Azalia Ortiz, Octavio Michel, Carmen Beato
## 3 Tedd Chan, Stella Chung, Henley Hii, Lawrence Koh, Tommy Kuan, Josh Lai, Mark Lee, Susan Leong, Benjamin Lim
## 4 Elijah Wood, John C. Reilly, Jennifer Connelly, Christopher Plummer, Crispin Glover, Martin Landau, Fred Tatasciore, Alan Oppenheimer, Tom Kane
## 5 Jim Sturgess, Kevin Spacey, Kate Bosworth, Aaron Yoo, Liza Lapira, Jacob Pitts, Laurence Fishburne, Jack McGee, Josh Gad, Sam Golzari, Helen Carey, Jack Gilpin
## 6 Erdal Beşikçioğlu, Yasemin Allen, Melis Birkan, Saygın Soysal, Berkan Şal, Metin Belgin, Ayça Eren, Selin Uludoğan, Özay Fecht, Suna Yıldızoğlu
## country date_added release_year rating duration
## 1 Brazil August 14, 2020 2020 TV-MA 4 Seasons
## 2 Mexico December 23, 2016 2016 TV-MA 93 min
## 3 Singapore December 20, 2018 2011 R 78 min
## 4 United States November 16, 2017 2009 PG-13 80 min
## 5 United States January 1, 2020 2008 PG-13 123 min
## 6 Turkey July 1, 2017 2016 TV-MA 1 Season
## listed_in
## 1 International TV Shows, TV Dramas, TV Sci-Fi & Fantasy
## 2 Dramas, International Movies
## 3 Horror Movies, International Movies
## 4 Action & Adventure, Independent Movies, Sci-Fi & Fantasy
## 5 Dramas
## 6 International TV Shows, TV Dramas, TV Mysteries
## description
## 1 In a future where the elite inhabit an island paradise far from the crowded slums, you get one chance to join the 3% saved from squalor.
## 2 After a devastating earthquake hits Mexico City, trapped survivors from all walks of life wait to be rescued while trying desperately to stay alive.
## 3 When an army recruit is found dead, his fellow soldiers are forced to confront a terrifying secret that's haunting their jungle island training camp.
## 4 In a postapocalyptic world, rag-doll robots hide in fear from dangerous machines out to exterminate them, until a brave newcomer joins the group.
## 5 A brilliant group of students become card-counting experts with the intent of swindling millions out of Las Vegas casinos by playing blackjack.
## 6 A genetics professor experiments with a treatment for his comatose sister that blends medical and shamanic cures, but unlocks a shocking side effect.
netflix_single_country <- netflix_data %>%
filter(!is.na(country)) %>%
filter(grepl(",", country) == FALSE)
country_counts <- netflix_single_country %>%
group_by(country) %>%
summarise(count = n()) %>%
arrange(desc(count))
top_10_countries <- head(country_counts, 10)
fig <- plot_ly(
data = top_10_countries,
labels = ~country,
values = ~count,
type = 'pie',
textinfo = 'label+percent',
hoverinfo = 'label+value'
)
fig
library(dplyr)
library(tidyr)
library(plotly)
top_10_countries <- netflix_data %>%
filter(!is.na(country)) %>%
separate_rows(country, sep = ",") %>%
group_by(country) %>%
summarise(total_content = n()) %>%
top_n(10, total_content) %>%
arrange(desc(total_content))
fig <- plot_ly(
type = 'table',
header = list(
values = c("País", "Total de Conteúdos"),
align = c('center', 'center'),
font = list(color = 'white', size = 12),
fill = list(color = 'gray')
),
cells = list(
values = list(top_10_countries$country, top_10_countries$total_content),
align = c('center', 'center'),
font = list(size = 12),
height = 30
)
)
fig
netflix_data <- netflix_data %>%
mutate(decade = floor(release_year / 10) * 10)
netflix_data_filtered <- netflix_data %>%
filter(!is.na(release_year)) %>%
filter(type %in% c("Movie", "TV Show"))
content_by_decade <- netflix_data_filtered %>%
group_by(decade, type) %>%
summarise(count = n(), .groups = 'drop') %>%
arrange(decade)
fig <- plot_ly(content_by_decade,
x = ~decade,
y = ~count,
color = ~type,
colors = c("orange", "blue"),
type = 'scatter',
mode = 'lines+markers',
marker = list(size = 8)) %>%
layout(title = "Quantidade de Conteúdo por Década",
xaxis = list(title = "Década"),
yaxis = list(title = "Quantidade de Conteúdo"),
showlegend = TRUE)
# Exibir o gráfico
fig
netflix_data_filtered <- netflix_data %>%
filter(release_year >= 2000 & release_year <= 2010) %>%
mutate(first_genre = sapply(strsplit(as.character(listed_in), ","), `[`, 1)) %>%
filter(first_genre %in% c("Dramas", "Action & Adventure", "Comedies"))
netflix_data_count <- netflix_data_filtered %>%
group_by(release_year, first_genre) %>%
summarise(count = n(), .groups = 'drop')
plot_ly(netflix_data_count, x = ~release_year, y = ~count, color = ~first_genre,
type = 'bar', barmode = 'group',
colors = c("blue", "green", "red")) %>%
layout(title = "Quantidade de Filmes Lançados (2000-2010) por Gênero",
xaxis = list(title = "Ano de Lançamento"),
yaxis = list(title = "Quantidade de Lançamentos"),
barmode = 'group')
## Warning: 'bar' objects don't have these attributes: 'barmode'
## Valid attributes include:
## '_deprecated', 'alignmentgroup', 'base', 'basesrc', 'cliponaxis', 'constraintext', 'customdata', 'customdatasrc', 'dx', 'dy', 'error_x', 'error_y', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'insidetextanchor', 'insidetextfont', 'legendgroup', 'legendgrouptitle', 'legendrank', 'marker', 'meta', 'metasrc', 'name', 'offset', 'offsetgroup', 'offsetsrc', 'opacity', 'orientation', 'outsidetextfont', 'selected', 'selectedpoints', 'showlegend', 'stream', 'text', 'textangle', 'textfont', 'textposition', 'textpositionsrc', 'textsrc', 'texttemplate', 'texttemplatesrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'width', 'widthsrc', 'x', 'x0', 'xaxis', 'xcalendar', 'xhoverformat', 'xperiod', 'xperiod0', 'xperiodalignment', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'yhoverformat', 'yperiod', 'yperiod0', 'yperiodalignment', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
## Warning: 'bar' objects don't have these attributes: 'barmode'
## Valid attributes include:
## '_deprecated', 'alignmentgroup', 'base', 'basesrc', 'cliponaxis', 'constraintext', 'customdata', 'customdatasrc', 'dx', 'dy', 'error_x', 'error_y', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'insidetextanchor', 'insidetextfont', 'legendgroup', 'legendgrouptitle', 'legendrank', 'marker', 'meta', 'metasrc', 'name', 'offset', 'offsetgroup', 'offsetsrc', 'opacity', 'orientation', 'outsidetextfont', 'selected', 'selectedpoints', 'showlegend', 'stream', 'text', 'textangle', 'textfont', 'textposition', 'textpositionsrc', 'textsrc', 'texttemplate', 'texttemplatesrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'width', 'widthsrc', 'x', 'x0', 'xaxis', 'xcalendar', 'xhoverformat', 'xperiod', 'xperiod0', 'xperiodalignment', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'yhoverformat', 'yperiod', 'yperiod0', 'yperiodalignment', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
## Warning: 'bar' objects don't have these attributes: 'barmode'
## Valid attributes include:
## '_deprecated', 'alignmentgroup', 'base', 'basesrc', 'cliponaxis', 'constraintext', 'customdata', 'customdatasrc', 'dx', 'dy', 'error_x', 'error_y', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'insidetextanchor', 'insidetextfont', 'legendgroup', 'legendgrouptitle', 'legendrank', 'marker', 'meta', 'metasrc', 'name', 'offset', 'offsetgroup', 'offsetsrc', 'opacity', 'orientation', 'outsidetextfont', 'selected', 'selectedpoints', 'showlegend', 'stream', 'text', 'textangle', 'textfont', 'textposition', 'textpositionsrc', 'textsrc', 'texttemplate', 'texttemplatesrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'width', 'widthsrc', 'x', 'x0', 'xaxis', 'xcalendar', 'xhoverformat', 'xperiod', 'xperiod0', 'xperiodalignment', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'yhoverformat', 'yperiod', 'yperiod0', 'yperiodalignment', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'